<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
	<style type="text/css">
		.tabs-container-list{
				border-bottom: 1px solid #e7eaec;
			}
			
		#tabb {
		    border-top: none !important;
		}	
	</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理>基本资料登记>客户资料登记</span>
		<a href="javascript:void(0)"></a>
	</div>
	<div class="buttonfixed" style="display: none;">
        <button type="button" class="btn dpbtn_blue" style="display: none;" id="allSave">提交初审</button>
		<button type="button" class="btn dpbtn_blue" style="display: none;" id="finalSave">提交终审</button>
		<button type="button" class="btn dpbtn_blue" style="display: none;" id="refuseSace">订单退回</button>
    </div>
	<div class="ibox-content ibox-con">
		<form class="form-horizontal" id="formbtSz">
			<%@include file="/jsp/common_yw_with_history_include.jsp"%>
		</form>
	</div>
	
	<c:if test="${ywBusinessDetail.busiStatus == 10 || ywBusinessDetail.busiStatus == 20 }">
		<div class="business-manwife">保存经销商及渠道类型</div>
		<div class="business-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table" style="margin-bottom: 0px;">
				<tr>
					<td align="left">
						<label class="control-label">订单类型：</label>
					</td>
					<td>
						<mytag:selectTag id="channelType" name="channelType" map="${channelType }" selected="${ywBusinessDetail.channelType }" others="class='select-control' required='required' onchange='changeChannelType();' style='width: 110px;'"/>
					</td>
					<td align="" class="changeChannelType" style="display: none;">
						<label class="control-label np">是否电审：</label>
					</td>
					<td class="changeChannelType" style="display: none;">
						<select id="ifPhone" name="ifPhone" class="select-control" style="width: 70px;">
							<option value="1" <c:if test="${empty ifPhone || ifPhone}">selected="selected"</c:if>>是</option>
							<option value="0" <c:if test="${!empty ifPhone && !ifPhone}">selected="selected"</c:if>>否</option>
						</select>		
					</td>
				</tr>
			</table>	
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
				<tr>
					<td align="left">
						<label class="control-label">改经销商：</label>
					</td>
					<td style="width:300px;">
						<input  class="form-control" type="hidden" id="business-dealerLevel" value="${ywBusinessDetail.dealerLevel}" />
						<input  class="form-control" type="hidden" id="business-cho" name="business-cho" value="${ywBusinessDetail.dealerId}" />
		    			<input id="p-business-cho" placeholder="经销商" readonly="readonly"  name="p-business-cho" type="text" value="${ywBusinessDetail.dealerName}"
		    			class="form-control smalliconcur smallicon"  onclick="businesscho('',false);">
					</td>
					<td>
						<button class="btn-danger-my dpbtn dpbtn_blue" type="button" onclick="changeDealerInfo();">保存数据</button>		
					</td>
				</tr>
			</table>
		</div>	
	</c:if>
	<div class="tab-bg">
		<div class="tab-width">
		   <div class="row m-b-lg">
	            <div class="col-sm-12">
	                <div class="tabs-container-list">
	                    <div class="tabs-left">
	                        <ul class="nav nav-tabs">
	                        	<li class="active"><a data-toggle="tab" href="#tab-7">征信信息</a></li>
	                            <li class=""><a data-toggle="tab" href="#tab-8" id="show_carinfor">贷前资料</a> </li>
	                            <li class=""><a data-toggle="tab" href="#tab-10" id="showfujian">身份证明</a> </li>
	                            <li class=""><a data-toggle="tab" href="#tab-9" id="attachment_files">附件归档</a> </li>
	                        </ul>
	                        <div class="tab-content">
	                        	<div id="tab-7" class="tab-pane active">
									<div class="panel-body">
									 	<div id="outerzx">
										    <ul id="tabzx">
										    	<li class="current">银行征信手工</li>
										        <li>银行征信接口</li>
										       <!--  <li>百融征信</li> -->
										    </ul>
										    <div id="contentzx">
										        <%@include file="/web/system/yw/zhengxin_include.jsp"%>
										    	<ul class="ul-style">
										            <%@include file="/web/system/kehubiao/jieKouZhengXin.jsp"%>
										    	</ul>
										    	<!-- <ul class="ul-style" style="display: none;">
										            <div class="business-padding">正在开发中</div>
										    	</ul> -->
										    </div>	    
	                        			</div>
	                        		</div>
	                        	</div>
	                        
	                        
	                            <div id="tab-8" class="tab-pane">
									<div class="panel-body">
									 	<div id="outer">
										    <ul id="tab">
										        <li class="current" id="carandloan">车辆&车贷</li>
										        <c:if test="${!empty ywBusinessBuyerItems}">
											        <c:forEach items="${ywBusinessBuyerItems }" var="ywBusinessBuyerItem">
											        	<c:if test="${ywBusinessBuyerItem.key == '03' && !empty ywBusinessBuyerItem.value}">
											        	 	<li>购车人</li>
											        	</c:if>
											        	<c:if test="${ywBusinessBuyerItem.key == '01' && !empty ywBusinessBuyerItem.value}">
											        		<li>共同购车人</li>
											        	</c:if>
											        	<c:if test="${ywBusinessBuyerItem.key == '02' && !empty ywBusinessBuyerItem.value}">
											        		<c:forEach items="${ywBusinessBuyerItem.value }" var="ywBusinessBuyer" varStatus="status">
											        			<c:choose>
											        				<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_1 }">
											        					<li>担保人一</li>
											        				</c:when>
											        				<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_2 }">
											        					<li>担保人二</li>
											        				</c:when>
											        				<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_3 }">
											        					<li>担保人三</li>
											        				</c:when>
											        				<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_4 }">
											        					<li>担保人四</li>
											        				</c:when>
											        			</c:choose>
											        		</c:forEach>
											        	</c:if>
											        </c:forEach>
										        </c:if>
										        <li>GPS信息</li>
										    </ul>
										    
										    <div id="content">
										       		 <!-- 车贷&车贷信息 -->
													<%@include file="/web/system/yw/cheliang_include.jsp"%>
													
													<c:if test="${!empty ywBusinessBuyerItems}">
												        <c:forEach items="${ywBusinessBuyerItems }" var="ywBusinessBuyerItem">
												        	<c:if test="${ywBusinessBuyerItem.key == '03' && !empty ywBusinessBuyerItem.value}">
												        		<c:forEach items="${ywBusinessBuyerItem.value }" var="ywBusinessBuyer" varStatus="status">
											        				<c:if test="${status.count == 1 }">
															       		 <!-- 购车人信息 -->
																		<%@include file="/web/system/yw/zhujieren_include.jsp"%>
												        			</c:if>
											        			</c:forEach>
												        	</c:if>
												        	<c:if test="${ywBusinessBuyerItem.key == '01' && !empty ywBusinessBuyerItem.value}">
												        		<c:forEach items="${ywBusinessBuyerItem.value }" var="ywBusinessBuyer" varStatus="status">
											        				<c:if test="${status.count == 1 }">
															       		 <!-- 共同购车人信息 -->
																		<%@include file="/web/system/yw/peiou_include.jsp"%>
												        			</c:if>
											        			</c:forEach>
												        	</c:if>
												        	<c:if test="${ywBusinessBuyerItem.key == '02' && !empty ywBusinessBuyerItem.value}">
												        		<c:forEach items="${ywBusinessBuyerItem.value }" var="ywBusinessBuyer" varStatus="status">
												        			<c:choose>
													        			<c:when test="${status.count == 1 }">
													        				<!-- 担保人 -->
																			<%@include file="/web/system/yw/danbaoren1_include.jsp"%>
													        			</c:when>
													        			<c:when test="${status.count == 2 }">
													        				<!-- 担保人 -->
																			<%@include file="/web/system/yw/danbaoren2_include.jsp"%>
													        			</c:when>
													        			<c:when test="${status.count == 3 }">
													        				<!-- 担保人 -->
																			<%@include file="/web/system/yw/danbaoren3_include.jsp"%>
													        			</c:when>
													        			<c:when test="${status.count == 4 }">
													        				<!-- 担保人 -->
																			<%@include file="/web/system/yw/danbaoren4_include.jsp"%>
													        			</c:when>
												        			</c:choose>
												        		</c:forEach>
												        	</c:if>
												        </c:forEach>
											        </c:if>
											         <!-- GPS信息 -->
													<%@include file="/web/system/yw/gps_include.jsp"%>
										    </div>
										</div>
									 	
									</div>
	                            </div>
	                            
	                            <div id="tab-10" class="tab-pane">
	                                <div class="panel-body">
	                                	<%@include file="/web/system/yw/sfzm_include.jsp"%>
	                                </div>
	                            </div>
	                            
	                            <div id="tab-9" class="tab-pane">
	                                <div class="panel-body">
	                                	   <!-- 附件信息 -->
	                                		<%@include file="/web/system/yw/fujian_include.jsp"%>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	         </div>
	      </div>
	</div>
</div>	

	
	<!-- 经销商-->
	<%@include file="/jsp/jxschoice_js_level_include.jsp"%>
    <%@include file="/jsp/comm_js_include.jsp"%>
 	<!-- summernote -->
 	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
 	<!-- 文件上传 -->
 	<%@include file="/jsp/common_fileupload_multi_include.jsp"%>
 	<!-- 区域选择 -->
 	<%@include file="/jsp/comm_js_region_include.jsp"%>
 	
 	<%@include file="/jsp/comm_js_region_include_choice.jsp"%>
 	
 	<!-- 车贷信息 -->
 	<%@include file="/web/system/yw/loan_js_include.jsp"%>
 	
 	<!-- layerDate plugin javascript -->
    <script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    <!-- custom js -->
	<script type="text/javascript" src="${basePath}/js/yw/gcr.js?v=${empty cssVersion ? Math.random() : cssVersion }" charset="utf-8"></script>
	<script type="text/javascript" src="${basePath}/js/yw/jkzx.js?v=${empty cssVersion ? Math.random() : cssVersion }" charset="utf-8"></script>
	
	<%@include file="/jsp/carchoice_js_include.jsp"%>
 	<%@include file="/web/system/yw/fujian_js_include.jsp"%>
 	<!-- 
 	    作者：程立勇
 	   描述：js脚本
 	 -->
 	<script type="text/javascript">
 	//经销商修改
	 	function changeDealerInfo(){
			var dealerId = $('#business-cho').val();
			var dealerName = $('#p-business-cho').val();
			var busiId = $('#busiId').val();
			var channelType = $('#channelType').val();
			var ifPhone = $('#ifPhone').val();
			var dealerLevel = $('#business-dealerLevel').val();
			if(!channelType || channelType == '') {
				layer.msg("请先选择订单类型", {icon: 5});
				return;
			}
			if(!dealerId || dealerId == '') {
				layer.msg("请先选择经销商", {icon: 5});
				return;
			}
			$.dpAjax({
				url:'${basePath}/YwBusinessController/changeChannel',
				data:{id:busiId,dealerId:dealerId,ifPhone:ifPhone,channelType:channelType},
				success:function(datas) {
					$('#dealerId').val(dealerId);
					$('#dealerLevel').text(dealerLevel + '级');
					$('#dealerName').text(dealerName);
					$('#channelTypeB').text($('#channelType option:selected').text());
					$('#ifPhoneB').text($('#ifPhone option:selected').text());
				}
			});
			
		}
 	
 	//手机号码归属地
 		function changephoneNo(obj){
	 		var $phoneArea = $(obj).parents("td").siblings(".locationAbout").find("input");
			var phone = obj.value;
			if(!phone || phone == ''){
				return;
			}
			$.dpAjax({
				show:false,
		    	url:'${basePath}/PhoneNumberAddrController/getAddressByPhoneNumber',
	 			data:{phoneCode:phone},
	 			success: function(datas){
	 				  var result = datas.result;
		 			  if(result && result != null){
		 				  var resultLocation = result.showapi_res_body;
						  var city = resultLocation.city;
						  if(city && city != ""){
							  $phoneArea.val(city);
						  }else{
							  $phoneArea.val("");
						  }
		 			  }else{
		 				 $phoneArea.val("");
					  }
	              }
	      	});
	    }
 		
 		function showPhodata(target){
 			var obj = $('#'+target+'_tel1');
			var phoneArea = $(obj).parents("td").siblings(".locationAbout").find("input");
 			var phoneAreaVal = phoneArea.val();
			var phone = $('#'+target+'_tel1').val();
			if(phoneAreaVal && phoneAreaVal != ""){
				return;
			}
			if(!phone || phone == ''){
				return;
			}
			$.dpAjax({
				show:false,
		    	url:'${basePath}/PhoneNumberAddrController/getAddressByPhoneNumber',
	 			data:{phoneCode:phone},
	 			success: function(datas){
	 				  var result = datas.result;
		 			  if(result && result != null){
		 				  var resultLocation = result.showapi_res_body;
						  var city = resultLocation.city;
						  if(city && city != ""){
							  phoneArea.val(city);
							  phoneArea.attr("readonly","readonly");
						  }else{
							  phoneArea.removeAttr("readonly","readonly");
						  }
		 			  }else{
		 				 phoneArea.removeAttr("readonly","readonly");
					  }
	              }
	      	});
 		}
 	
 	/* 省市区默认选择 */
	 	var hujilayer,objid,objidPhone;
	 	
	 	function cityChoice(obj){
	 		selectProvincesLayer(null,function(){
	 			$selectedProvice = $("#provincechioce").children("li:eq(0)")
	 			$selectedProvice.addClass("proactive"); 
	 			selectCitiesLayer("110000000000",null, function(){
	 				$("#citychioce").children("li:eq(0)").addClass("proactive"); 
		 			selectAreasLayer("110100000000");
		    	});
	 		});
	 		objid = $(obj).attr("id");
	 		 
	 		hujilayer = layer.open({
	 			type:1,
	 			title:"省市选择",
	 			area: ['650px', '500px'], //宽高
	 			content: $("#areaChoice")
	 		});
	 	};
	 	
	 	function areachoiceone(obj){
	 		var province = $("#provincechioce").find("li.proactive").text();
	 		var city = $("#citychioce").find("li.proactive").text();
	 		var area = $(obj).text();
	 		if(area =="未知地区"){
	 			area =" ";
	 		}
	 		var text = province + city + area;
	 		if(objid=="zhujieren_familyRegister"){
	 			$("#zhujieren_familyRegister").val(text);
	 		}else if(objid=="zhujieren_area"){
	 			$("#zhujieren_area").val(text);
	 		}else if(objid=="registrationArea"){
	 			$("#registrationArea").val(text);
	 		}else if(objid=="peiou_familyRegister"){
	 			$("#peiou_familyRegister").val(text);
	 		}else if(objid=="peiou_area"){
	 			$("#peiou_area").val(text);
	 		}else if(objid=="danbaoren1_familyRegister"){
	 			$("#danbaoren1_familyRegister").val(text);
	 		}else if(objid=="danbaoren1_area"){//担保人1户籍
	 			$("#danbaoren1_area").val(text);
	 		}else if(objid=="danbaoren2_familyRegister"){
	 			$("#danbaoren2_familyRegister").val(text);	
	 		}else if(objid=="danbaoren2_area"){
	 			$("#danbaoren2_area").val(text);
	 		}else if(objid=="danbaoren3_familyRegister"){
	 			$("#danbaoren3_familyRegister").val(text);	
	 		}else if(objid=="danbaoren3_area"){
	 			$("#danbaoren3_area").val(text);
	 		}else if(objid=="danbaoren4_familyRegister"){
	 			$("#danbaoren4_familyRegister").val(text);	
	 		}else if(objid=="danbaoren4_area"){
	 			$("#danbaoren4_area").val(text);
	 		}	
	 		layer.close(hujilayer);
	 	} 
	 	
	 	//手机号码归属地2级
	 	function poneCitychoicelayer(obj){
	 		/* 省市默认选择 */
	 		phoneProvinces(null,function(){
	 			phoneCities("110000000000");
	    		$("#provincechioceTwo").children("li:eq(0)").addClass("proactive");
		    });
	 		
	 		objidPhone = $(obj).attr("id");
	 		 
	 		hujilayer = layer.open({
	 			type:1,
	 			title:"省市选择",
	 			area: ['410px', '500px'], //宽高
	 			content: $("#areaChoiceTwo")
	 		});
	 	}
 	
 		function poneCitychoice(obj){
 			var pooneArea = $(obj).text();
 			if(objidPhone=="zhujieren_tel1Area"){
	 			$("#zhujieren_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="zhujieren_tel2Area"){
	 			$("#zhujieren_tel2Area").val(pooneArea);
	 		}else if(objidPhone=="peiou_tel1Area"){
	 			$("#peiou_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren1_tel1Area"){
	 			$("#danbaoren1_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren1_tel2Area"){
	 			$("#danbaoren1_tel2Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren2_tel1Area"){
	 			$("#danbaoren2_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren2_tel2Area"){
	 			$("#danbaoren2_tel2Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren3_tel1Area"){
	 			$("#danbaoren3_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren3_tel2Area"){
	 			$("#danbaoren3_tel2Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren4_tel1Area"){
	 			$("#danbaoren4_tel1Area").val(pooneArea);
	 		}else if(objidPhone=="danbaoren4_tel2Area"){
	 			$("#danbaoren4_tel2Area").val(pooneArea);
	 		}
 			layer.close(hujilayer);
 		}
	 	
 		//改变在职状态
	 	function changeJobStatus(target){
	 		var status = $('#' + target + '_jobStatus').val();
	 		if(!status || status == '') {
	 			status = '01';
	 			$('#' + target + '_jobStatus').val('01');
	 		}
	 		if('01' == status) { //在职
		    	$('.' + target +'_job_status_rel_remark').hide();
		    	$('.' + target +'_job_status_rel').show();
	 		} else if('02' == status){ //自由职业
		    	$('.' + target +'_job_status_rel').hide();
		    	$('.' + target +'_job_status_rel_remark').show();
	 		}
	 		
	 		changeAffiliateStatus(target);
	    }
 		
 		function changeAffiliateStatus(target) {
 			var jobStatus = $('#' + target + '_jobStatus').val();
 			if('01' == jobStatus) { //在职
	 			var status = $('#' + target + '_affiliateStatus').val();
	 			if(!status || status == '') {
		 			status = '01';
		 			$('#' + target + '_affiliateStatus').val('01');
		 		}
	 			if('01' == status) { //不挂靠
			    	$('.' + target +'_affiliate_status_rel').hide();
		 		} else if('02' == status){ //挂靠
		 			$('.' + target +'_affiliate_status_rel').show();
		 		}
 			} else if('02' == status){ //自由职业
 				$('.' + target +'_job_status_rel').hide();
		    	$('.' + target +'_job_status_rel_remark').show();
 			}
 		}
		
 		//改变为二手车,默认没有改变车辆性质
        var saveLoanBeforeCar = false;
 		var hasLoan = false;
	 	$(document).ready(function () {
	 		 <c:if test="${!empty ywBusinessBuyerItems}">
		        <c:forEach items="${ywBusinessBuyerItems }" var="ywBusinessBuyerItem">
		        	<c:if test="${ywBusinessBuyerItem.key == '03' && !empty ywBusinessBuyerItem.value}">
		        	   $('#zhujieren_remarks').summernote({
			  	            lang: 'zh-CN',
			  	            toolbar:[
			  					['style', ['bold', 'italic', 'underline', 'clear']],
			  					['color', ['color']]
			  	            ]
			  	        });
		        	   $('#saveZhujieren').click(function(){
			   	        	var validstatus = $("#commentForm").valid();
			   	 		    if(validstatus){
			   	        		saveGcr('zhujieren');
			   	 		    }
				   	 		else{
			        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
			        		}
			   	        });
		        	   
		        	    $('#zhujieren_jobStatus').change(function(){
		        		   changeJobStatus('zhujieren');
			   	        });
		        	    $('#zhujieren_affiliateStatus').change(function(){
		        		   changeAffiliateStatus('zhujieren');
			   	        });
		        	</c:if>
		        	<c:if test="${ywBusinessBuyerItem.key == '01' && !empty ywBusinessBuyerItem.value}">
			        	$('#peiou_remarks').summernote({
				            lang: 'zh-CN',
				            toolbar:[
								['style', ['bold', 'italic', 'underline', 'clear']],
								['color', ['color']]
				            ]
				        });
			        	$('#savePeiou').click(function(){
			   				var validstatus = $("#commentFormb").valid();
			   			    if(validstatus){
			   					saveGcr('peiou');
			   			    }
			   			 	else{
			        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
			        		}
			   	        });
			        	
			        	 $('#peiou_jobStatus').change(function(){
			        		   changeJobStatus('peiou');
				   	      });
			        	 $('#peiou_affiliateStatus').change(function(){
			        		   changeAffiliateStatus('peiou');
				   	      });
		        	</c:if>
		        	<c:if test="${ywBusinessBuyerItem.key == '02' && !empty ywBusinessBuyerItem.value}">
			        	<c:forEach items="${ywBusinessBuyerItem.value }" var="ywBusinessBuyer" varStatus="status">
		        			<c:choose>
			        			<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_1 }">
			        			   $('#danbaoren1_remarks').summernote({
			        		            lang: 'zh-CN',
			        		            toolbar:[
			        						['style', ['bold', 'italic', 'underline', 'clear']],
			        						['color', ['color']]
			        		            ]
			        		        });
			        			   $('#saveDanbaoren1').click(function(){
						   				var validstatus = $("#commentForme").valid();
						   			    if(validstatus){
						   					saveGcr('danbaoren1');
						   			    }
						   			 	else{
						        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
						        		}
						   	        });
						        	
						        	 $('#danbaoren1_jobStatus').change(function(){
						        		   changeJobStatus('danbaoren1');
							   	      });
						        	 $('#danbaoren1_affiliateStatus').change(function(){
						        		   changeAffiliateStatus('danbaoren1');
							   	      });
			        			</c:when>
			        			<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_2 }">
				        			$('#danbaoren2_remarks').summernote({
			        		            lang: 'zh-CN',
			        		            toolbar:[
			        						['style', ['bold', 'italic', 'underline', 'clear']],
			        						['color', ['color']]
			        		            ]
			        		        });
				        			 $('#saveDanbaoren2').click(function(){
							   				var validstatus = $("#commentFormf").valid();
							   			    if(validstatus){
							   					saveGcr('danbaoren2');
							   			    }
								   			 else{
								        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
								        		}
							   	        });
						        	
						        	 $('#danbaoren2_jobStatus').change(function(){
						        		   changeJobStatus('danbaoren2');
							   	      });
						        	 $('#danbaoren2_affiliateStatus').change(function(){
						        		   changeAffiliateStatus('danbaoren2');
							   	      });
			        			</c:when>
			        			<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_3 }">
				        			$('#danbaoren3_remarks').summernote({
			        		            lang: 'zh-CN',
			        		            toolbar:[
			        						['style', ['bold', 'italic', 'underline', 'clear']],
			        						['color', ['color']]
			        		            ]
			        		        });
				        			 $('#saveDanbaoren3').click(function(){
							   				var validstatus = $("#commentFormg").valid();
							   			    if(validstatus){
							   					saveGcr('danbaoren3');
							   			    }
							   			 	else{
							        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
							        		}
							   	        });
						        	
						        	 $('#danbaoren3_jobStatus').change(function(){
						        		   changeJobStatus('danbaoren3');
							   	      });
						        	 $('#danbaoren3_affiliateStatus').change(function(){
						        		   changeAffiliateStatus('danbaoren3');
							   	      });
			        			</c:when>
			        			<c:when test="${ywBusinessBuyer.cusNo == DAN_BAO_REN_CUS_NO_4 }">
				        			$('#danbaoren4_remarks').summernote({
			        		            lang: 'zh-CN',
			        		            toolbar:[
			        						['style', ['bold', 'italic', 'underline', 'clear']],
			        						['color', ['color']]
			        		            ]
			        		        });
				        			 $('#saveDanbaoren4').click(function(){
						   				var validstatus = $("#commentFormh").valid();
						   			    if(validstatus){
						   					saveGcr('danbaoren4');
						   			    }
						   			 	else{
						        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
						        		}
						   	        });
						        	
						        	 $('#danbaoren4_jobStatus').change(function(){
						        		   changeJobStatus('danbaoren4');
							   	      });
						        	 $('#danbaoren4_affiliateStatus').change(function(){
						        		   changeAffiliateStatus('danbaoren4');
							   	      });
			        			</c:when>
		        			</c:choose>
		        		</c:forEach>
		        	</c:if>
		        </c:forEach>
	        </c:if>
	        
	        
	        $('#car_remarks').summernote({
	            lang: 'zh-CN',
	            toolbar:[
					['style', ['bold', 'italic', 'underline', 'clear']],
					['color', ['color']]
	            ]
	        });
	        
	        //内置选项卡
	        var $li = $('#tab>li');
			var $ul = $('#content .ul-style');

	        $li.click(function(){
				var $this = $(this);
				var $t = $this.index();
				$li.removeClass();
				$this.addClass('current');
				$ul.css('display','none');
				$ul.eq($t).css('display','block');
			});
	        
	      //内置选项卡
	        var $lib = $('#tabb>li');
			var $ulb = $('#contentb .ul-style');
	        $lib.click(function(){
				var $this = $(this);
				var $t = $this.index();
				$lib.removeClass();
				$this.addClass('currentb');
				$ulb.css('display','none');
				$ulb.eq($t).css('display','block');
			});
	        
	      //内置选项卡
	        var $lizx = $('#tabzx>li');
	    	var $ulzx = $('#contentzx .ul-style');
	        $lizx.click(function(){
	    		var $this = $(this);
	    		var $t = $this.index();
	    		$lizx.removeClass();
	    		$this.addClass('current');
	    		$ulzx.css('display','none');
	    		$ulzx.eq($t).css('display','block');
	    	});
	        
	        var $lisfzm = $('#tabsfzm>li');
	    	var $ulsfzm = $('#contentsfzm .ul-style');
	    		$lisfzm.click(function(){
	    			var $this = $(this);
	    			var $t = $this.index();
	    			$lisfzm.removeClass();
	    			$this.addClass('currentb');
	    			$ulsfzm.css('display','none');
	    			$ulsfzm.eq($t).css('display','block');
	    	});	
	        //判断二手车显示估价
	        $("#carType").change(function(){
	        	if($("#carType").val() == '02'){
	        		saveLoanBeforeCar = hasLoan;
	        	} else {
	        		saveLoanBeforeCar = false;
	        	}
	        	var carAreaPrice = $('#exactEstimationResult').html();
	        	if($("#carType").val() == '02' && (carAreaPrice && '' != carAreaPrice)) { //二手车，已经估价
					hasExactEstimationResult();
				 } else if($("#carType").val() == '02' && (!carAreaPrice || '' == carAreaPrice)){  //没有评估
    				hasNotExactEstimationResult();
				 } else { //新车
					notUsedCar();
				 }
	        	adapterCarType();
	        	countLoanMonth();
	        });
	        
	        //提交终审
	        $('#finalSave').click(function(){
	        	var ywbtxx = $("#channelType").val();
	        	if(ywbtxx ==""){
	        		layer.msg("请在本订单头部选择订单类型！",{icon:2});
	        		return;
	        	}
	        	comitFinal();
	        });
	        //订单退回
	        $('#refuseSace').click(function(){
	        	layer.confirm('订单退回后，将退回到资料登记阶段，需初审重审。是否继续？', {
      			  btn: ['确定','取消'] //按钮
	      		},function(){
	      			refuseSace();
	      		});
	        });
	        
	        $('#allSave').click(function(){
	        	var ywbtxx = $("#channelType").val();
	        	if(ywbtxx ==""){
	        		layer.msg("请在本订单头部选择订单类型！",{icon:2});
	        		return;
	        	}
	        	var isAllAction = true;
		        	saveYw(function(){
	       				saveCar(function(){
		        			var zhujieren = $('#zhujieren_idno');
		        			if(zhujieren && zhujieren.length > 0) {
		        				var validstatus = $("#commentForm").valid();
		        			    if(validstatus){
			        				saveGcr('zhujieren',function(){
			        				},isAllAction,false);
		        			    }
		        			}
		        			var peiou = $('#peiou_idno');
		        			if(peiou && peiou.length > 0) {
		        				var validstatus = $("#commentFormb").valid();
		        			    if(validstatus){
			        				saveGcr('peiou',function(){
			        					
			        				},isAllAction,false);
		        			    }
		        			}
       					
		        			var danbaoren1 = $('#danbaoren1_idno');
		        			if(danbaoren1 && danbaoren1.length > 0) {
		        				var validstatus = $("#commentForme").valid();
		        			    if(validstatus){
			        				saveGcr('danbaoren1',function(){
			        					
			        				},isAllAction,false);
		        			    }
		        			}
		        			var danbaoren2 = $('#danbaoren2_idno');
		        			if(danbaoren2 && danbaoren2.length > 0) {
		        				var validstatus = $("#commentFormf").valid();
		        			    if(validstatus){
			        				saveGcr('danbaoren2',function(){
			        					
			        				},isAllAction,false);
		        			    }
		        			}
		        			var danbaoren3 = $('#danbaoren3_idno');
		        			if(danbaoren3 && danbaoren3.length > 0) {
		        				var validstatus = $("#commentFormg").valid();
			        			if(validstatus){
			        				saveGcr('danbaoren3',function(){
			        					
			        				},isAllAction,false);
		        			    }
		        			}
		        			var danbaoren4 = $('#danbaoren4_idno');
		        			if(danbaoren4 && danbaoren4.length > 0) {
		        				var validstatus = $("#commentFormh").valid();
			        			if(validstatus){
			        				saveGcr('danbaoren4',function(){
			        					
			        				},isAllAction,false);
			        			 }
		        			}
		        			checkCompleted();
	       				},isAllAction);
	        	},isAllAction);
	        });
	        
	        $('#saveCar').click(function(){
	        	if(saveLoanBeforeCar) {
	        		layer.msg("二手车需要重新计算估价，否则无法保存！",{icon:2});
	        		return;
	        	}
	        	var carBrand = document.getElementById("carBrand").value ;
	        	var carSeries = document.getElementById("carSeries").value;
	        	var carModel = document.getElementById("carModel").value;
	        	var nameCarBrand = document.getElementById("nameCarBrand").value;
	        	var nameCarSeries = document.getElementById("nameCarSeries").value;
	        	var nameCarModel = document.getElementById("nameCarModel").value;
	        	var carId = document.getElementById("carId").value;
	        	if(carBrand == "" || carSeries == "" || carModel== "" || nameCarBrand== "" || nameCarBrand== "" || nameCarSeries== ""){
	        		layer.msg("车系车型录入出错，请联系管理员！",{icon:5});
	        		return;
	        	}
	        	var validstatus = $("#commentFormc").valid();
			    if(validstatus){
			    	saveCar();
			    }
			    else{
        			layer.msg("有验证未通过，请仔细检查！",{icon:7});
        		}
	        });
	        
	        $('#exactEstimation').click(function(){
	        	var validstatus = $("#commentFormc").valid();
	        	if(validstatus){
	        		estimate();
			    }
	        	else{
        			layer.msg("有验证未通过，请仔细检查！",{icon:7})
        		}
	        });
	        
	        $('#saveLoan').click(function(){
        		saveLoan(function() {
        			saveLoanBeforeCar = false;
        			hasLoan = true;
        		});
	        });
	        $('#attachment_files').click(function(){
	        	showFujian();
	        });
	        
	        $("#showfujian").click(function(){
	        	showFujian();
	        	$("#right_tabl_16").click();
	        });
	        
	        $('#show_carinfor').click(function(){
	        	$('#carandloan').click();
	        });
	        
	        //放事件后，可能需要解绑事件
	        getData();
	        xitongguJia(); 
	    });
	 	
	 	//提交终审
	 	function comitFinal(){
	 		layer.confirm('确认提交终审？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
				  btn: ['确认','取消'] //按钮
				}, function(){
			 		$('.buttonfixed').hide();
			 		$.dpAjax({
			 			show:true,
				    	url:'${basePath}/YwBusinessController/comitFinal',
			 			data:{id:$.getUrlData('id')},
			 			success: function(datas){
			 				$('.buttonfixed').hide();
			 				layer.msg('提交终审成功!', {icon: 6,time:1000});
			 				/* setTimeout(function(){
		     					location.href='${basePath}/web/system/yw/ywBussiness.jsp'; 
		     				 },3000); */
			             }
				    });
				})
	 	}
	 	
	 	//订单退回
	 	function refuseSace(){
	 		$.dpAjax({
		    	url:'${basePath}/YwBusinessController/refuseSace',
	 			data:{id:$.getUrlData('id')},
	 			success: function(datas){
	 				$('.buttonfixed').show();
					$('#allSave').show();
					$('.saveInfo').show();
					$('#finalSave').hide();
					$('#refuseSace').hide();
					
	 				layer.msg('订单退回成功!', {icon: 6,time:1000});
	 				setTimeout(function(){
     					location.href='${basePath}/web/system/yw/ywBussiness.jsp'; 
     				 },3000);
	             }
		    });
	 	}
	 	
	 	/* 弹窗嵌套估价 */
	 	function xitongguJia(){
	 		$.dpAjax({
		    	url:'${basePath}/DataDictionaryController/getEnableList',
	 			data:{"parentValue":"Website_Usedcar"},
	 			success: function(datas){
 					  var result = datas.result.rows;
 					  var content="";
 					  for(var i=0; i<result.length;i++){
 						  var href = result[i].remarks;
 						  var name = result[i].name;
 						  content +='<div class="gujiamenu btn dpbtn_green" onclick="layeropen(\''+href+'\')">'+name+'</div>';
 					  }
 					 $("#xitongGj").append(content);
	              }
		   });
	 	}
	 	
	 	function layeropen(href){
	 	   layer.open({
			  type: 2,
			  area: ['80%', '80%'], //宽高
			  content:href,
			});
	 	} 
	 	
 	 	function changeIdNo(){
        	var UUserCard = $("#peiou_idno").val(); 
	 		if(UUserCard != null && UUserCard != ''){
	 		//获取年龄 
	 		var myDate = new Date(); 
	 		var month = myDate.getMonth() + 1; 
	 		var day = myDate.getDate();
	 		var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1; 
	 		if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) { 
	 			age++; 
	 		}
	 			$("#peiou_age").val(age);
	 		}
	 		else{
	 			$("#peiou_age").val("");
	 		}
        }
	 	
	 	function adapterCarType(){
		    warning();
        	if($("#carType").val() == '02') {
        		$('.usedCar').show();
        		$('#carAge').attr('required','');
        		$('#carEstimatePrice').attr('required','');
        	} else {
        		$('.usedCar').hide();
        		$('#carAge').removeAttr('required');
        		$('#carEstimatePrice').removeAttr('required');
        	}
        }
	 	function showWarningUsedIcbc(){
	 		$('#zhkcj_show').text('已＞80% 建议调整');
	 		$('#qyhkcj_show').text('已＞70% 建议调整');
	 	}
	 	function showWarningNewIcbc(){
	 		$('#zhkcj_show').text('已＞90% 建议调整');
	 		$('#qyhkcj_show').text('已＞80% 建议调整');
	 	}
	 	function showWarningUsedBoc(){
	 		$('#zhkcj_show').text('已＞70% 建议调整');
	 		$('#qyhkcj_show').text('已＞70% 建议调整');
	 	}
	    function getData(){
	    	$.dpAjax({
        		show:false,
 	    		url:'${basePath}/YwBusinessController/getMultiById',
     			data:{id: $.getUrlData('id')},
     			success: function(datas){
	     			  if(datas.flag == "100100")
 					  {
	     				 var result = datas.result;
	     				 //贷款银行
	     				 var loanBanks = result.loanBanks;
	     				 if(loanBanks) {
	     					 var html = '';
	     					 for(var i in loanBanks) {
	     						 var loanBank = loanBanks[i];
	     						 html += '<option value="'+loanBank.value +'">' + loanBank.name +'</option>';
	     					 }
	     					$('#loanBank').html(html);
	     				 } else {
	     					 $('#loanBank').html('<option value="">--没有配置贷款银行--</option>');
	     				 }
	     				 
	     				//取整模式
	     				 var intTypes = result.intTypes;
	     				 if(intTypes) {
	     					 var html = '';
	     					 for(var i in intTypes) {
	     						 var intType = intTypes[i];
	     						 html += '<option value="' + intType.value +'">'+intType.name +'</option>';
	     					 }
	     					$('#ccol1').html(html);
	     				 } else {
	     					 $('#ccol1').html('<option value="">--没有配置取整模式--</option>');
	     				 }
	     				 
	     				//业务信息
		     				var ywBusinessDetail = result.ywBusinessDetail;
		     				if(ywBusinessDetail) {
		     					/* $('#busiId').val(ywBusinessDetail.replaceId);
		     					$('#queryCreditApplyId').val(ywBusinessDetail.queryCreditApplyId);
		     					$('#creditQueryId').val(ywBusinessDetail.creditQueryId);
		     					$('#dealerId').val(ywBusinessDetail.dealerId);
		     					$('#customerId').val(ywBusinessDetail.customerId);
		     					$('#customerName').html(ywBusinessDetail.customerName);
		     					$('#customerNo').html(ywBusinessDetail.customerNo);
		     					$('#busiCode').html(ywBusinessDetail.busiCode);
		     					$('#orgName').html(ywBusinessDetail.orgName);
		     					$('#salesmanName').html(ywBusinessDetail.salesmanName);
		     					$('#dealerLevel').html(ywBusinessDetail.dealerLevelDisplay);
		     					$('#dealerName').html(ywBusinessDetail.dealerName); */
		     					if(ywBusinessDetail.channelType && ywBusinessDetail.channelType != '') {
		     						$('#channelType').val(ywBusinessDetail.channelType);
		     						changeChannelType();
		     					}
		     					/* $('#channelType').html(ywBusinessDetail.channelTypeDisplay); */
		     					/* $('#channelStatus').val(ywBusinessDetail.channelStatus); */
		     					/* $('#channelStatus').html(ywBusinessDetail.channelStatusDisplay); */
		     					//全部提交按钮
		     					var busiStatus = ywBusinessDetail.busiStatus;
		     					if(busiStatus) {
		     						if(busiStatus < ${CHU_SHEN_DAN_CHU_SHEN_ZHONG}) {//提交初审显示
		     							$('.buttonfixed').show();
		     							$('#allSave').show();
			     						$('.saveInfo').show();
			     						$('#finalSave').hide();
			     						$('#refuseSace').hide();
			     						
		     						}else if(busiStatus >= ${CHU_SHEN_DAN_CHU_SHEN_ZHONG} && busiStatus < ${QIAN_SHU_HE_TONG_ZHONG}){//全隐藏
		     							$('.buttonfixed').hide();
		     							$('#allSave').hide();
			     						$('.saveInfo').hide();
			     						$('#finalSave').hide();
			     						$('#refuseSace').hide();
			     						
			     						$('#channelType').attr('disabled','disabled');
			     						$('#ifPhone').attr('disabled','disabled');
		     						} else if(busiStatus == ${QIAN_SHU_HE_TONG_ZHONG}) {//提交终审显示
		     							$('.buttonfixed').show();
		     							$('#finalSave').show();
		     							$('#refuseSace').show();
		     							$('#allSave').hide();
			     						$('.saveInfo').hide();
			     						
			     						$('#channelType').attr('disabled','disabled');
			     						$('#ifPhone').attr('disabled','disabled');
		     						} else if(busiStatus > ${QIAN_SHU_HE_TONG_ZHONG}){//全隐藏
			     						$('.buttonfixed').hide();
		     							$('#allSave').hide();
			     						$('.saveInfo').hide();
			     						$('#finalSave').hide();
			     						$('#refuseSace').hide();
			     						
			     						$('#channelType').attr('disabled','disabled');
			     						$('#ifPhone').attr('disabled','disabled');
		     						} else {
		     							//没有这种情况
		     						}
		     					} else {
	     							//没有这种情况
	     						}
		     				}
		     				
	     				 //征信信息
	     				 /* var zxCreditQueryDetails = result.zxCreditQueryDetails;
	     				 if(zxCreditQueryDetails) {
		     				 for(var key in zxCreditQueryDetails) {
		     					var target = '';
			     				 if(key == '03') {
			     					target = 'z'; //购车人
			     				 }else if(key == '01') {
			     					target = 'p';//共同购车人
			     				 } else if(key == '02') {
			     					target = 'd';//担保人
			     				 }
			     				var zxCreditQueryPartDetails = zxCreditQueryDetails[key];
			     				if(zxCreditQueryPartDetails && zxCreditQueryPartDetails.length > 0){
			     					showZx(target, zxCreditQueryPartDetails);
			     				}
		     				 }
	     				 } */
	     				 var zxCreditQuerys = result.zxCreditQuerys;
	     				 if(zxCreditQuerys && zxCreditQuerys.length > 0) {
		     				 for(var i in zxCreditQuerys) {
			     				showZx(zxCreditQuerys[i]);
		     				 }
	     				 }
	     				 
	     				//购车人信息
	     				 var ywBusinessBuyers = result.ywBusinessBuyers;
	     				 if(ywBusinessBuyers) {
		     				 for(var key in ywBusinessBuyers) {
				     			 var ywBusinessPartBuyers = ywBusinessBuyers[key];
				     			 if(!ywBusinessPartBuyers || ywBusinessPartBuyers.length == 0){
				     				 continue;
				     			 }
		     					 var target = '';
			     				 if(key == '03') {
			     					target = 'zhujieren'; //购车人
				     				showBuer(target, ywBusinessPartBuyers[0]);
			     				 } else if(key == '01') {
			     					target = 'peiou';//共同购车人
			     					showBuer(target, ywBusinessPartBuyers[0]);
			     				 } else if(key == '02'){
			     					target = 'danbaoren';//担保人
			     					showBuers(target, ywBusinessPartBuyers);
			     				 }
		     				 }
	     				 }
	     				changeIdNo();
	     				 
	     				
	     				//车辆信息
	     				var ywBusinessCar = result.ywBusinessCar;
	     				if(ywBusinessCar) {
	     					$('#carId').val(ywBusinessCar.replaceId);
	     					var carBrand = ywBusinessCar.carBrand;
							var carSeries = ywBusinessCar.carSeries;
							var carModel = ywBusinessCar.carModel;
							$('#carBrand').val(carBrand);
							$('#carSeries').val(carSeries);
							$('#carModel').val(carModel);
							var nameCarBrand = ywBusinessCar.nameCarBrand;
							var nameCarSeries = ywBusinessCar.nameCarSeries;
							var nameCarModel = ywBusinessCar.nameCarModel;
							$('#nameCarBrand').val(nameCarBrand);
							$('#nameCarSeries').val(nameCarSeries);
							$('#nameCarModel').val(nameCarModel);
							$('#carName').val(nameCarModel);
							$('#categoryCar').val(ywBusinessCar.categoryCar);
							$('#priceNewcar').val(ywBusinessCar.priceNewcar);
							$('#carType').val(ywBusinessCar.carType);
							$('#carPlace').val(ywBusinessCar.carPlace);
							$('#seatNum').val(ywBusinessCar.seatNum);
							var price = ywBusinessCar.price ? ywBusinessCar.price.toFixed(2) : '';
							$('#price').val(price);
							$('#carPrice').val(price);
							$('#registrationArea').val(ywBusinessCar.registrationArea);
							$('#licencePlateType').val(ywBusinessCar.licencePlateType);
							$('#carOwnersName').val(ywBusinessCar.carOwnersName);
							$('#vin').val(ywBusinessCar.vin);
							$('#startDate').val(ywBusinessCar.startDate ? formateToDate(ywBusinessCar.startDate) : '');
							$('#startYear').val(ywBusinessCar.startYear);
							$('#startMonth').val(ywBusinessCar.startMonth);
							$('#carStatus').val(ywBusinessCar.carStatus);
							$('#carPurpose').val(ywBusinessCar.carPurpose);
							$('#categoryCar').val(ywBusinessCar.categoryCar);
							$('#mileage').val(ywBusinessCar.mileage);
							$('#car_remarks').code(ywBusinessCar.remarks);
							var province = ywBusinessCar.evaluateProvince;
							$('#province').val(province);
							var city = ywBusinessCar.evaluateCity;
							$('#city').val(city);
							selectCities(province, city);
	     				}
	     				
	     				//车贷信息
	     				var ywBusinessLoan = result.ywBusinessLoan;
	     				if(ywBusinessLoan) {
	     					hasLoan = true;
	     					if(!ywBusinessLoan.loanBank || ywBusinessLoan.loanBank == '') {
	     						initLoanBankAndType();
	     					}
	     					showLoanData(ywBusinessLoan);
	     				} else {
	     					initLoanBankAndType();
	     				}
	     				
	     				//控制估价显隐
	     				adapterCarType();
	     				//控制贷款模式显隐
	     				countLoanMonth();
	     				  
	     				 //估价
	     				 var carAreaPrice = result.carAreaPrice;
	     				$('#exactEstimationResult').html(carAreaPrice);
	     				 if($("#carType").val() =='02' && (carAreaPrice && '' != carAreaPrice)) {//二手车，并已经评估过
	     					hasExactEstimationResult();
	     				 } else if($("#carType").val() =='02' && (!carAreaPrice || '' == carAreaPrice)){ //二手车，还没有评估
	     					hasNotExactEstimationResult();
	     				 } else { //新车
	     					notUsedCar();
	     				 }
 						 return;
 					  }
 					  if(datas.flag == "100200")
 	                  {
 						  $.fn.showDatas({"datas":datas});
 	                	  return;
 	                  }
 					  layer.msg(datas.message, {icon: 2});
                 }
 	    	});
	 	}
	    
	   function saveGcr(target, fn, isAllAction,syn){
		   var zhujieren = $('#zhujieren_idno').val();
			var peiou = $('#peiou_idno').val();
			var danbaoren1 = $('#danbaoren1_idno').val();
			var danbaoren2 = $('#danbaoren2_idno').val();
			var danbaoren3 = $('#danbaoren3_idno').val();
			var danbaoren4 = $('#danbaoren4_idno').val();
			
			var idNos = [];
			if(zhujieren && zhujieren != '') {
				idNos.push(zhujieren.trim());
			}
			if(peiou && peiou != '') {
				idNos.push(peiou.trim());
			}
			if(danbaoren1 && danbaoren1 != '') {
				idNos.push(danbaoren1.trim());
			}
			if(danbaoren2 && danbaoren2 != '') {
				idNos.push(danbaoren2.trim());
			}
			if(danbaoren3 && danbaoren3 != '') {
				idNos.push(danbaoren3.trim());
			}
			if(danbaoren4 && danbaoren4 != '') {
				idNos.push(danbaoren4.trim());
			}
			if(idNos.length > 0) {
				for(var i = 0; i < idNos.length; i++) {
					var thisIdNo = idNos[i];
					for(var j = i + 1; j < idNos.length; j++) {
						var targetIdNo = idNos[j];
						if(thisIdNo == targetIdNo) {
							layer.msg("身份证不能重复", {icon: 5});
							return;
						}
					}
				}
			}
		   target = target || 'zhujieren';
		   var data = {};
		   var id = $('#'+target+'_id').val();
		   data.busiId = $("#busiId").val();
	 	   data.cusId = $("#customerId").val();
		   data.name=$('#'+target+'_name').val();
		   data.education=$('#'+target+'_education').val();
		   data.familyRegister=$('#'+target+'_familyRegister').val();
		   data.sex=$('#'+target+'_sex').val();
		   data.idno=$('#'+target+'_idno').val();
		   data.area=$('#'+target+'_area').val();
		   data.tel1=$('#'+target+'_tel1').val();
		   data.tel1Area=$('#'+target+'_tel1Area').val();
		   var jobStatus = $('#'+target+'_jobStatus').val();
		   data.jobStatus=$('#'+target+'_jobStatus').val();
		   data.affiliateStatus=$('#'+target+'_affiliateStatus').val();
		   data.company=$('#'+target+'_company').val();
		   if("01" == jobStatus) {
		   	  data.companyIncome=$('#'+target+'_companyIncome').val();
		   } else if("02" == jobStatus){
			  data.companyIncome=$('#'+target+'_companyIncome_remark').val();
		   }
		   data.companyAddr=$('#'+target+'_companyAddr').val();
		   data.job=$('#'+target+'_job').val();
		   data.monthIncome=$('#'+target+'_monthIncome').val();
		   data.workAge=$('#'+target+'_workAge').val();
		   data.companyTel=$('#'+target+'_companyTel').val();
		   data.remarks=$('#'+target+'_remarks').code();
		   if(target=='zhujieren' || target=='danbaoren1' || target=='danbaoren2' || target=='danbaoren3' || target=='danbaoren4') {
			   data.maritalStatus=$('#'+target+'_maritalStatus').val();
			   data.postcode=$('#'+target+'_postcode').val();
			   data.tel2=$('#'+target+'_tel2').val();
			   data.tel2Area=$('#'+target+'_tel2Area').val();
			   data.nowAddr=$('#'+target+'_nowAddr').val();
			   data.nowTel=$('#'+target+'_nowTel').val();
			   data.familyAddr=$('#'+target+'_familyAddr').val();
			   data.familyTel=$('#'+target+'_familyTel').val();
			   data.contact1=$('#'+target+'_contact1').val();
			   data.contact1Tel1=$('#'+target+'_contact1Tel1').val();
			   data.contact1Tel2=$('#'+target+'_contact1Tel2').val();
			   data.contact1Relation=$('#'+target+'_contact1Relation').val();
			   data.contact2=$('#'+target+'_contact2').val();
			   data.contact2Tel1=$('#'+target+'_contact2Tel1').val();
			   data.contact2Tel2=$('#'+target+'_contact2Tel2').val();
			   data.contact2Relation=$('#'+target+'_contact2Relation').val();
	    	} else if(target=='peiou') {
	    	   data.age=$('#'+target+'_age').val();
	    	}
		   var url = '';
		   if(id && id != ''){
		   	   data.id=id;
			   url = '${basePath}/YwBusinessBuyerController/modify';
		   } else {
		   	   url = '${basePath}/YwBusinessBuyerController/save';
			  if(target=='zhujieren') {
				  data.carManType='03';
			  } else if(target=='peiou'){
				  data.carManType='01';
			  } else if(target=='danbaoren1'){
				  data.carManType='02';
			  } else if(target=='danbaoren2'){
				  data.carManType='02';
			  } else if(target=='danbaoren3'){
				  data.carManType='02';
			  } else if(target=='danbaoren4'){
				  data.carManType='02';
			  }
		   }
		   $.dpAjax({
       			show:true,
       			async:syn,
	    		url:url,
    			data:data,
    			success: function(datas){
     				$('#'+target+'_id').val(datas.result);
     				if(fn){
     				 	fn();
     				 } else {
     					if(!isAllAction) {
     						layer.msg("保存成功！", {icon: 6});
     					}
     				 }
                }
	    	});
	   }
	   
	   function showBuers(target, ywBusinessPartBuyers) {
		   for(var i = 0; i < ywBusinessPartBuyers.length; i++) {
			   var ywBusinessPartBuyer = ywBusinessPartBuyers[i];
			   var $idnos = $("input[value='"+ywBusinessPartBuyer.idno+"']");
			   if($idnos && $idnos.length == 1) {
				   var idnoDom = $idnos[0];
				   var idNo = $(idnoDom).attr('id');
				   var target = idNo.split('_')[0];
				   if(target) {
				   		showBuer(target, ywBusinessPartBuyer);
				   }
			   }
		   }
	   }
	    
	    //展示购车人
	    function showBuer(target, ywBusinessPartBuyer) {
	    	showBuerData(target, ywBusinessPartBuyer);
	    	if(target=='zhujieren' || target=='danbaoren1' || target=='danbaoren2' || target=='danbaoren3' || target=='danbaoren4') {
	    		if(ywBusinessPartBuyer.maritalStatus && ywBusinessPartBuyer.maritalStatus != '') {
	    			$('#'+target+'_maritalStatus').val(ywBusinessPartBuyer.maritalStatus);
	    		}
	    		$('#'+target+'_postcode').val(ywBusinessPartBuyer.postcode);
	    		$('#'+target+'_tel2').val(ywBusinessPartBuyer.tel2);
	    		$('#'+target+'_tel2Area').val(ywBusinessPartBuyer.tel2Area);
	    		$('#'+target+'_nowAddr').val(ywBusinessPartBuyer.nowAddr);
	    		$('#'+target+'_nowTel').val(ywBusinessPartBuyer.nowTel);
	    		$('#'+target+'_familyAddr').val(ywBusinessPartBuyer.familyAddr);
	    		$('#'+target+'_familyTel').val(ywBusinessPartBuyer.familyTel);
	    		$('#'+target+'_contact1').val(ywBusinessPartBuyer.contact1);
	    		$('#'+target+'_contact1Tel1').val(ywBusinessPartBuyer.contact1Tel1);
	    		$('#'+target+'_contact1Tel2').val(ywBusinessPartBuyer.contact1Tel2);
	    		if(ywBusinessPartBuyer.contact1Relation && ywBusinessPartBuyer.contact1Relation != ''){
	    			$('#'+target+'_contact1Relation').val(ywBusinessPartBuyer.contact1Relation);
	    		}
	    		$('#'+target+'_contact2').val(ywBusinessPartBuyer.contact2);
	    		$('#'+target+'_contact2Tel1').val(ywBusinessPartBuyer.contact2Tel1);
	    		$('#'+target+'_contact2Tel2').val(ywBusinessPartBuyer.contact2Tel2);
	    		if(ywBusinessPartBuyer.contact2Relation && ywBusinessPartBuyer.contact2Relation != '') {
	    			$('#'+target+'_contact2Relation').val(ywBusinessPartBuyer.contact2Relation);
	    		}
	    	} else if(target=='peiou') {
	    		if(ywBusinessPartBuyer.age && ywBusinessPartBuyer.age != '') {
    				$('#'+target+'_age').val(ywBusinessPartBuyer.age);
	    		}
	    	}
	    	
	    	changeJobStatus(target);
	    	changeAffiliateStatus(target);
	    }
	    function showBuerData(target, ywBusinessPartBuyer) {
    		$('#'+target+'_id').val(ywBusinessPartBuyer.replaceId);
    		$('#'+target+'_name').val(ywBusinessPartBuyer.name);
    		if(ywBusinessPartBuyer.education && ywBusinessPartBuyer.education != '') {
    			$('#'+target+'_education').val(ywBusinessPartBuyer.education);
    		}
    		$('#'+target+'_familyRegister').val(ywBusinessPartBuyer.familyRegister);
    		if(ywBusinessPartBuyer.sex && ywBusinessPartBuyer.sex != ''){
    			$('#'+target+'_sex').val(ywBusinessPartBuyer.sex);
    		}
    		$('#'+target+'_idno').val(ywBusinessPartBuyer.idno);
    		$('#'+target+'_area').val(ywBusinessPartBuyer.area);
    		$('#'+target+'_tel1').val(ywBusinessPartBuyer.tel1);
    		showPhodata(target);
    		$('#'+target+'_tel1Area').val(ywBusinessPartBuyer.tel1Area);
    		var jobStatus = ywBusinessPartBuyer.jobStatus;
    		if(jobStatus && jobStatus != '') {
    			$('#' + target + '_jobStatus').val(jobStatus);
    		}
    		if(ywBusinessPartBuyer.affiliateStatus && ywBusinessPartBuyer.affiliateStatus != ''){
    			$('#'+target+'_affiliateStatus').val(ywBusinessPartBuyer.affiliateStatus);
    		}
    		$('#'+target+'_company').val(ywBusinessPartBuyer.company);
    		if("01" == jobStatus) {
	   		   	  $('#'+target+'_companyIncome').val(ywBusinessPartBuyer.companyIncome);
	   		   } else if("02" == jobStatus){
	   			 $('#'+target+'_companyIncome_remark').val(ywBusinessPartBuyer.companyIncome);
	   		   }
    		$('#'+target+'_companyAddr').val(ywBusinessPartBuyer.companyAddr);
    		if(ywBusinessPartBuyer.job && ywBusinessPartBuyer.job != '') {
    			$('#'+target+'_job').val(ywBusinessPartBuyer.job);
    		}
    		$('#'+target+'_monthIncome').val(ywBusinessPartBuyer.monthIncome);
    		if(ywBusinessPartBuyer.workAge && ywBusinessPartBuyer.workAge != '') {
    			$('#'+target+'_workAge').val(ywBusinessPartBuyer.workAge);
    		}
    		$('#'+target+'_companyTel').val(ywBusinessPartBuyer.companyTel);
    		$('#'+target+'_remarks').code(ywBusinessPartBuyer.remarks);
	    }
	    
	    //展示征信信息
	    /* function showZx(target, zxCreditQueryPartDetails){
	    	if(target == 'z') {
	    		var zxCreditQueryPartDetail = zxCreditQueryPartDetails[0];
	    		showZxData(target, zxCreditQueryPartDetail);
	    		$('#'+target+'_label').show();
	    		$('#'+target+'_div').show();
	    	} else if(target=='p'){
	    		var zxCreditQueryPartDetail = zxCreditQueryPartDetails[0];
	    		if(zxCreditQueryPartDetail){
		    		showZxData(target, zxCreditQueryPartDetail);
		    		$('#'+target+'_label').show();
		    		$('#'+target+'_div').show();
	    		}
	    	} else if(target == 'd') {
	    		for(var i = 0; i < 4; i++){
	    			var zxCreditQueryPartDetail = zxCreditQueryPartDetails[i];
	    			if(zxCreditQueryPartDetail) {
		    			showZxData(target+(i+1), zxCreditQueryPartDetails[i]);
		    			$('#'+target+(i+1)+'_label').show();
			    		$('#'+target+(i+1)+'_div').show();
	    			}
	    		}
	    	}
	    } */
	    
	    /**
	     *展示征信
	     */
	    function showZx(zxCreditQuery){
	    	var target = '';
	    	if(zxCreditQuery.cusNo == '${CUS_NO}') {
	    		target = 'z'
	    		//贷款银行第一次赋值
	    		queryBankCode = zxCreditQuery.bankCode;
	    	} else if(zxCreditQuery.cusNo == '${PEI_OU_CUS_NO}') {
	    		target = 'p'
	    	} else if(zxCreditQuery.cusNo == '${DAN_BAO_REN_CUS_NO_1}') {
	    		target = 'd1'
	    	} else if(zxCreditQuery.cusNo == '${DAN_BAO_REN_CUS_NO_2}') {
	    		target = 'd2'
	    	} else if(zxCreditQuery.cusNo == '${DAN_BAO_REN_CUS_NO_3}') {
	    		target = 'd3'
	    	} else if(zxCreditQuery.cusNo == '${DAN_BAO_REN_CUS_NO_4}') {
	    		target = 'd4'
	    	}
	    	showZxData(target, zxCreditQuery);
	    	$('#'+target+'_label').show();
    		$('#'+target+'_div').show();
	    }
	    
	    function showZxData(target, zxCreditQueryPartDetail) {
    		$('#'+target+'_zxCreditQueryId').val(zxCreditQueryPartDetail.replaceId);
    		$('#'+target+'_cusName').html(zxCreditQueryPartDetail.cusName);
    		$('#'+target+'_cusNo').html(zxCreditQueryPartDetail.cusNo);
    		$('#'+target+'_operatorDate').html(formateIntegerMinutes(zxCreditQueryPartDetail.modified));
    		$('#'+target+'_bankCode').html(zxCreditQueryPartDetail.bankCodeDisplay);
    		$('#'+target+'_creditResult').html(zxCreditQueryPartDetail.creditResultDisplay);
    		$('#'+target+'_onceCarStatus').html(zxCreditQueryPartDetail.onceCarStatusDisplay);
    		$('#'+target+'_creditResultMark').html(zxCreditQueryPartDetail.creditResultMark);
    		getJkZxcx('${basePath}/BaseCustomerController/zxcxDetail');
	    }
	    
	    
		function notUsedCar(){ //新车
			$('#used-car tr:gt(3)').hide();
			$('#exactEstimation').hide();
			$('#exactEstimationResult').hide();
	    }
	    
	    function hasExactEstimationResult(){ //二手车，并已经评估过
	    	$('#used-car tr:gt(3)').show();
	    	$('#exactEstimation').text('重新估价');
	    	$('#exactEstimation').show();
	    	$('#exactEstimationResult').show();
	    }
	    
		function hasNotExactEstimationResult(){ //二手车，还没有评估
			$('#used-car tr:gt(3)').show();
	    	$('#exactEstimation').text('系统估价');
	    	$('#exactEstimation').show();
	    	$('#exactEstimationResult').hide();
	    }
		
		function estimate(){
			var carId = $("#carId").val();
			if(!carId || carId == '') {
				layer.msg("请先保存车辆信息！", {icon: 5});
				return;
			}
			var data = {};
	 		data.busiId = $("#busiId").val();
	 		data.carId = carId;
	 		data.carStatus = $("#carStatus").val();
	 		data.purpose = $("#carPurpose").val();
	 		data.province = $("#province").val();
	 		data.city = $("#city").val();
	 		data.price = $("#price").val() / 10000;//单位万元
	 		data.brand = $("#carBrand").val();
	 		data.series = $("#carSeries").val();
	 		data.car = $("#carModel").val();
	 		data.mileage = $("#mileage").val();
	 		data.usedDate = $("#startYear").val();
	 		data.usedDateMonth = $("#startMonth").val();
	 		
	 		var carSeries = $("#carSeries").val();
        	$.dpAjax({
        		show:true,
 	    		url:'${basePath}/YwBusinessCarAreaPriceController/estimate',
     			data:data,
     			success: function(datas){
     				 var carAreaPrice = datas.result;
     				 if($("#carType").val() =='02' && carAreaPrice && carAreaPrice.length > 0) {
     					 var html = '经评估，该二手车估价 ';
     					 for(var i = 0; i<carAreaPrice.length; i++) {
     						var price = carAreaPrice[i].price;
     						html += ' <span class="gujianame">' + carAreaPrice[i].areaName + '：</span><span class="gujiaprice">' + price + (/^(-?\d+)(\.\d+)?$/.test(price) ? '万':'') + '</span>';
     					 }
     					$('#exactEstimationResult').html(html);
     					hasExactEstimationResult();
     				 } else if($("#carType").val() =='02' && (!carAreaPrice || carAreaPrice.length == 0)){ //二手车，还没有评估
	     				hasNotExactEstimationResult();
     				 } else { //新车
     					notUsedCar();
   				 	 }
                 }
 	    	});
		}
		
		function saveCar(fn, isAllAction){
			saveCarAction(fn, isAllAction);
		}
		
		function checkIfNeedEstimate(){
			var carType = $("#carType").val();
			if(carType !='02') {
				return;
			}
			var data = {};
	 		data.busiId = $("#busiId").val();
	 		data.carId = $("#carId").val();
	 		data.carStatus = $("#carStatus").val();
	 		data.purpose = $("#carPurpose").val();
	 		data.province = $("#province").val();
	 		data.city = $("#city").val();
	 		data.price = $("#price").val();
	 		data.brand = $("#carBrand").val();
	 		data.series = $("#carSeries").val();
	 		data.car = $("#carModel").val();
	 		data.mileage = $("#mileage").val();
	 		data.usedDate = $("#startYear").val();
	 		data.usedDateMonth = $("#startMonth").val();
			$.dpAjax({
 	    		url:'${basePath}/YwBusinessCarAreaPriceController/checkIfNeedEstimate',
     			data:data,
     			success: function(datas){
                 }
 	    	});
		}
		
		function saveCarAction(fn, isAllAction){
			var data = {};
			var id = $('#carId').val();
			data.busiId = $("#busiId").val();
	 		data.cusId = $("#customerId").val();
			data.carBrand = $('#carBrand').val();
			data.nameCarBrand  = $('#nameCarBrand').val();
			data.carSeries = $('#carSeries').val();
			data.nameCarSeries  = $('#nameCarSeries').val();
			data.carModel = $('#carModel').val();
			data.nameCarModel  = $('#nameCarModel').val();
			data.priceNewcar  = $('#priceNewcar').val();
			data.carType = $('#carType').val();
			data.carPlace = $('#carPlace').val();
			data.seatNum = $('#seatNum').val();
			data.price = $('#price').val();
			data.registrationArea = $('#registrationArea').val();
			data.licencePlateType = $('#licencePlateType').val();
			data.carOwnersName = $('#carOwnersName').val();
			data.categoryCar =  $('#categoryCar').val();
			data.vin = $('#vin').val();
			data.startDate = $('#startDate').val();
			data.startYear = $('#startYear').val();
			data.startMonth = $('#startMonth').val();
			data.carStatus = $('#carStatus').val();
			data.carPurpose = $('#carPurpose').val();
			data.mileage = $('#mileage').val();
			data.evaluateProvince = $('#province').val();
			data.evaluateCity = $('#city').val();
			data.remarks = $('#car_remarks').code();
			var url = '';
			if(id && id != '') {
				data.id= id;
				url = '${basePath}/YwBusinessCarController/modify';
			} else {
				url = '${basePath}/YwBusinessCarController/save';
			}
			$.dpAjax({
 	    		url:url,
     			data:data,
     			success: function(datas){
     				 if(!isAllAction) {
     				 	layer.msg('车辆信息保存成功', {icon: 6});
     				 }
     				 $('#carId').val(datas.result);
     				 if(fn){
     				 	fn();
     				 }
                 }
 	    	});
		}
		//保存业务
		function saveYw(fn,isAllAction) {
			var data = {};
			var channelType = $('#channelType').val();
			if(!channelType || channelType == '') {
				channelType = $('#channelTypeC').val();
			}
			data.channelType = channelType;
			/* data.channelStatus = $('#channelStatus').val(); */
			data.id = $('#busiId').val();
			layer.confirm('确认提交初审？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			  btn: ['确认','取消'] //按钮
			}, function(){
				layer.closeAll();
				$.dpAjax({
	 	    		url:'${basePath}/YwBusinessController/saveStatus',
	     			data:data,
	     			success: function(datas){
	     				 if(fn){
	     				 	fn();
	     				 }
	                 }
	 	    	});
			})
		}
		//确认信息完整
		function checkCompleted(){
			$.dpAjax({
        		show:true,
 	    		url:'${basePath}/YwBusinessController/checkCompleted',
     			data:{id: $.getUrlData('id'), modeId:"${modeIDTypeNames.ZLDJ}",ifPhone:$('#ifPhone').val()},
     			success: function(datas){
     				layer.closeAll();
	     			location.href='${basePath}/web/system/yw/ywBussiness.jsp';
                 }
 	    	});
		}
		
</script>
<script type="text/javascript">
	$(document).ready(function () {
		changeChannelType();
		$('#saveGps').click(function(){
			var validstatus = $("#commentFormGPS").valid();
			if(validstatus){
				var data = {};
				data.valueExtras = $('#valueExtras').val();
				data.busiId = $('#busiId').val();
				data.typeExtras = '${ADD_GPS_TYPE}';
				data.codeExtras = '${ADD_GPS_CODE}';
				data.nameExtras = '${ADD_GPS_NAME}';
				var id = $('#gpsId').val();
				var url;
				if(id && id != '') {
					data.id = id;
					url = '${basePath}/YwBusinessExtrasController/modify';
				} else {
					url = '${basePath}/YwBusinessExtrasController/save';
				}
				$.dpAjax({
					url:url,
					data:data,
					success:function(datas) {
						$('#gpsId').val(datas.result);
					}
				});
			}	
		});
		
		var channelTypec = $("#channelTypeC").val();
		if(channelTypec == '30'){
			$('.changeChannelTypeC').show();
		} else {
			$('.changeChannelTypeC').hide();
		}
		
	});
	
	function changeChannelType(){
		var channelType = $('#channelType').val();
		if(channelType == '30'){
			$('.changeChannelType').show();
		} else {
			$('.changeChannelType').hide();
		}
	}
</script>
</body>
</html>
